home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / utility / uwserver.zip / uwserver.tar / doc / uwlib.ms < prev    next >
Text File  |  1991-01-25  |  25KB  |  797 lines

  1. .\" This file should be processed by nroff or troff with the -ms macro set
  2. .ds uw \s-2UW\s0
  3. .DA September 30, 1986
  4. .TL
  5. The UW Programmer's Library
  6. .AU
  7. John D. Bruner
  8. .SH
  9. Introduction
  10. .PP
  11. \*(uw is a multiple-window Macintosh interface to a 4.2BSD UNIX\**.
  12. .FS
  13. Macintosh is a trademark of McIntosh Laboratories which
  14. is licensed to Apple Computer, Inc.
  15. UNIX is a registered trademark of Bell Laboratories.
  16. .FE
  17. \*(uw version 3 comprises a server,
  18. a set of utility programs,
  19. and an program-level interface.
  20. This manual describes the services which are available
  21. in the \*(uw programmer's library.
  22. This library allow programs to create,
  23. communicate with,
  24. and perform some control operations upon
  25. windows on the Macintosh.
  26. .SH
  27. Background
  28. .PP
  29. Before the library routines themselves can be discussed,
  30. it is necessary to consider some aspects of the \*(uw
  31. server.
  32. The server which was distributed with \*(uw versions 1.6 and 2.10
  33. communicated with the Macintosh using a protocol which
  34. is referred to as the ``original protocol.''
  35. The version 3 server is capable of communicating in this protocol;
  36. however,
  37. it also supports an ``extended protocol.''
  38. For convenience,
  39. these protocols are assigned numbers:
  40. protocol 1 is the original protocol
  41. and protocol 2 is the extended protocol.
  42. .PP
  43. Protocol 1 provides a mechanism for
  44. the creation and destruction of windows
  45. as well as a means to multiplex a single
  46. communications line among several windows.
  47. It provides a mechanism for transmitting
  48. control and ``meta'' characters,
  49. and it also provides two ``maintenance functions''
  50. which are used for startup and shutdown.
  51. .PP
  52. Protocol 2 provides two significant enhancements
  53. relative to protocol 1.
  54. First,
  55. window creation messages specify the window emulation type
  56. (\fIe.g.\fP adm-31, vt52).
  57. Second,
  58. additional information about windows,
  59. called ``window options,''
  60. is transmitted between the Macintosh client and the
  61. server on the host.
  62. .PP
  63. Window options are an ``out-of-band'' channel of
  64. information between the Macintosh and the host.
  65. There are two types:
  66. generic
  67. (common to all window types)
  68. and emulation-specific.
  69. The following are generic:
  70. .DS
  71. window visibility
  72. window type
  73. window position (pixel address of top left corner)
  74. window title
  75. window size in pixels
  76. .DE
  77. The following window options are specific to
  78. cursor-addressible terminal emulations:
  79. .DS
  80. terminal size (number of rows and columns)
  81. font size index (small=0, large=1)
  82. mouse handling (clipboard or encoded send-to-host)
  83. bell characteristics (audible, visible)
  84. cursor appearance (block or underscore)
  85. .DE
  86. .PP
  87. The server distinguishes between two window classes \(em
  88. internal and external.
  89. Internal windows are handled entirely by the server.
  90. They are always terminal emulations and are always
  91. associated with a pseudo-terminal device.
  92. .PP
  93. By contrast,
  94. an external window always involves some outside process.
  95. The server communicates with this process through one
  96. or two Internet domain network connections.
  97. There is always a ``data'' connection,
  98. through which the external process exchanges information
  99. (indirectly, through the server)
  100. with the Macintosh.
  101. There may also be a ``control'' connection
  102. through which the external process exchanges
  103. window option information
  104. (again indirectly)
  105. with the Macintosh.
  106. The server acts as a multiplexor and demultiplexor
  107. for external windows.
  108. It also caches window option information;
  109. however,
  110. it does not perform host-end emulation-specific tasks.
  111. .PP
  112. Internal and external windows meet different needs.
  113. Terminal emulation on the local host is best performed
  114. by internal windows,
  115. because fewer processes are involved
  116. (and response time is better).
  117. External windows are suitable for remote processes
  118. (\fIi.e.\fP those on another Internet host)
  119. or for non-terminal tasks such as file transfer.
  120. The \*(uw application library contains routines
  121. to create and manipulate both classes of windows.
  122. .SH
  123. Window ID's and Network Addresses
  124. .PP
  125. A unique 32-bit identification number is associated
  126. with each window that a server manipulates.
  127. Some operations
  128. (described below)
  129. require the window number to be specified.
  130. When the server creates a new internal window,
  131. it passes the window ID as the environment variable
  132. ``UW_ID''.
  133. .PP
  134. The server creates two network sockets upon which to receive
  135. incoming messages.
  136. One socket receives UNIX-domain datagrams,
  137. the other listens for Internet-domain stream connections.
  138. The addresses of these sockets are placed in the environment
  139. as the variables ``UW_UIPC''
  140. (UNIX-domain)
  141. and ``UW_INET''
  142. (Internet domain).
  143. .SH
  144. Data Types and Data Structures
  145. .PP
  146. The \*(uw programmer's library uses a number
  147. of simple and structured data types.
  148. .IP uwid_t 1i
  149. Unique window ID numbers are represented by the data type ``uwid_t''.
  150. .IP UWIN
  151. Library routines which operate upon external windows
  152. put a range of window information into a structure.
  153. The type ``UWIN'' is a pointer to the structure.
  154. An object of this datatype is referred to as a ``window descriptor.''
  155. This declaration is intended to be used as an abstract unit
  156. (in the manner of the standard I/O library's ``FILE\ *'').
  157. .IP uwtype_t
  158. Window emulation types have the data type ``uwtype_t''.
  159. The following emulation types are defined:
  160. .DS
  161. .ta 8n 24n 32n
  162. #define    UWT_ADM31    0    /* ADM-31 cursor-addressible terminal */
  163. #define    UWT_VT52    1    /* VT52 cursor-addressible terminal */
  164. #define    UWT_ANSI    2    /* ANSI-compatible terminal */
  165. #define    UWT_TEK4010    3    /* Tektronix 4010 graphics terminal */
  166. #define    UWT_FTP    4    /* File transfer */
  167. #define    UWT_PRINT    5    /* Output to Macintosh printer */
  168. .DE
  169. .IP uwopt_t
  170. Window options are assigned numbers whose type is ``uwopt_t''.
  171. The names of the options are:
  172. .DS
  173. .ta 8n 28n 32n
  174. #define    UWOP_VIS    1    /* visibility */
  175. #define    UWOP_TYPE    2    /* window type */
  176. #define    UWOP_POS    3    /* window position */
  177. #define    UWOP_TITLE    4    /* window title */
  178. #define    UWOP_WSIZE    5    /* window size (in bits) */
  179. #define    UWOP_TSIZE    8    /* terminal size (row,col) */
  180. #define    UWOP_TFONTSZ    9    /* small/large font size */
  181. #define    UWOP_TCLIPB    10    /* clipboard/mouse encoding */
  182. #define    UWOP_TBELL    11    /* audible, visual bell */
  183. #define    UWOP_TCURS    12    /* cursor shape */
  184. .DE
  185. .IP uwoptcmd_t
  186. The window option commands
  187. which are passed between the Macintosh and the host
  188. have type ``uwoptcmd_t''.
  189. These commands are:
  190. .DS
  191. .ta 8n 24n 32n
  192. #define    UWOC_SET    0        /* set value of option */
  193. #define    UWOC_ASK    2        /* ask for value of option */
  194. #define    UWOC_DO    4        /* report changes in value */
  195. #define    UWOC_DONT    5        /* don't report changes */
  196. #define    UWOC_WILL    6        /* will report changes */
  197. #define    UWOC_WONT    7        /* won't report changes */
  198. .DE
  199. .IP "union uwoptval"
  200. When a function requires a window option value as an argument,
  201. the value of the window option is placed into a
  202. union declared as ``union uwoptval''.
  203. The address of this union is passed to the function.
  204. This union is declared as follows:
  205. .DS
  206. .ta 8n 16n 24n
  207. union uwoptval {
  208.     unsigned char    uwov_1bit;
  209.     unsigned char    uwov_2bit;
  210.     unsigned char    uwov_6bit;
  211.     unsigned short    uwov_12bit;
  212.     struct {
  213.         unsigned short v,h;
  214.     }        uwov_point;
  215.     char        uwov_string[256];
  216. };
  217. .DE
  218. The union member used for a particular option
  219. depends upon the option number.
  220. At present,
  221. the types of the window options and
  222. corresponding union members are:
  223. .DS
  224. .ta 1i
  225. visibility    uwov_1bit
  226. type    uwov_6bit
  227. position    uwov_point
  228. title        uwov_string (null terminated)
  229. bit size    uwov_point
  230. tty size    uwov_point
  231. font size    uwov_1bit
  232. clipboard    uwov_1bit
  233. bell        uwov_2bit
  234. cursor type    uwov_1bit
  235. .DE
  236. .IP "uwerr_t"
  237. When a library routine returns an error indication,
  238. further information about the type of error can be
  239. obtained from the global variable ``uwerrno''.
  240. (Depending upon the type of error,
  241. the external variable ``errno'' may also contain
  242. pertinent information.)
  243. \*(uw error numbers have type ``uwerr_t'',
  244. and are defined as follows:
  245. .DS
  246. .ta 8n 24n 32n
  247. #define    UWE_NONE    0    /* no error */
  248. #define    UWE_ERRNO    1    /* system call error, consult errno */
  249. #define    UWE_NXTYPE    2    /* nonexistent window type */
  250. #define    UWE_DUPID    3    /* window ID duplicated (in use) */
  251. #define    UWE_NOTIMPL    4    /* operation not implemented yet */
  252. #define    UWE_NXSERV    5    /* non-existent server */
  253. #define    UWE_NOMEM    6    /* unable to allocate required memory */
  254. #define    UWE_INVAL    7    /* invalid argument to function */
  255. #define    UWE_NOCTL    8    /* no control file descriptor */
  256. .DE
  257. .SH
  258. Internal Window Interface
  259. .PP
  260. When an internal window is created by an external process,
  261. a UNIX-domain datagram is sent to the server.
  262. This datagram contains
  263. (as ``access rights'')
  264. a file descriptor for the ``master'' side of a pseudo-terminal.
  265. The server assumes that the external process
  266. has started some program on the ``slave'' side of the pseudo-terminal.
  267. After sending the datagram,
  268. the sender has no direct handle to manipulate
  269. the window.
  270. It has,
  271. in effect,
  272. relinquished all control.
  273. (It should close the master side of the pseudo-terminal
  274. after sending the datagram.)
  275. To provide some additional flexibility,
  276. it is possible to change the value of a window option
  277. for any window
  278. (even ``external'' windows)
  279. if the window's unique ID is known.
  280. The creator of the window has no special privileges
  281. in this regard.
  282. .LP
  283. [One thing which the internal window routines
  284. in the \*(uw library completely ignore
  285. is the fact that datagrams are not guaranteed to be reliable.
  286. UNIX-domain datagrams almost always seem to work,
  287. but they can fail.
  288. In the author's experience this has never been a problem,
  289. but let the user beware.]
  290. .LP
  291. The following routines are available:
  292. .IP uw_fork 1i
  293. This routine is similar in concept to the system call ``fork''.
  294. It creates a new process
  295. and returns twice \(em
  296. once in the parent and once in the child.
  297. In addition to creating a new process,
  298. ``uw_fork'' also arranges for the new process to be
  299. associated with an internal window.
  300. It opens a pseudo-terminal,
  301. redirects the child's standard input,
  302. standard output,
  303. and standard error,
  304. and sends a UNIX-domain datagram to the \*(uw server.
  305. It returns the unique ID associated with the window
  306. in the parent,
  307. and returns 0 in the child.
  308. (\(mi1 is returned if the routine fails.)
  309. .DS
  310. uwid_t uw_fork(uwtype_t wtype, int *pidp);
  311. .DE
  312. The first argument specifies the type of the new window.
  313. If the second argument to ``uw_fork'' is a non-NULL pointer,
  314. the process-ID of the child will be stored at that address
  315. in the parent process.
  316. (In the child, ``*pidp'' will be zero.)
  317. .IP uw_cmd
  318. This routine builds upon the functionality of the ``uw_fork'' routine.
  319. It creates a new window with ``uw_fork''
  320. and then executes a specified command.
  321. It takes the window type,
  322. the name of an executable file,
  323. and an argument list
  324. as parameters;
  325. it uses these as arguments to ``uw_fork''
  326. and the C library routine ``execvp''.
  327. It returns the window ID number to its caller:
  328. .DS
  329. uwid_t uw_cmd(uwtype_t wtype, char *file, char **argv);
  330. .DE
  331. (\(mi1 is returned if the routine fails.)
  332. .IP uw_shell
  333. ``uw_shell'' is similar to ``uw_cmd'' except that it
  334. executes an arbitrary shell command:
  335. .DS
  336. uwid_t uw_shell(uwtype_t wtype, char *cmd);
  337. .DE
  338. (\(mi1 is returned if the routine fails.)
  339. By default the Bourne shell is used;
  340. however,
  341. the shell may be changed by patching the global variable ``uwshellname''.
  342. .DS
  343. char *uwshellname = "/bin/sh";
  344. .DE
  345. .IP uw_rsetopt
  346. This routine changes the value of a window option
  347. for an existing window
  348. (named as a window ID).
  349. The window may be either internal or external.
  350. The specified window option is set to a desired value.
  351. Zero is returned if the appropriate UNIX-domain message
  352. was successfully sent;
  353. \(mi1 is returned if the operation failed.
  354. (Since ``uw_rsetopt'' does not receive a reply from the server,
  355. it is unable to determine whether or not the command ``succeeded''.
  356. Rather,
  357. it returns zero if the command was successfully transmitted.)
  358. .DS
  359. int uw_rsetopt(uwid_t uwid, uwopt_t optnum, union uwoptval *optval);
  360. .DE
  361. ``optval'' points to a ``union uwoptval'' structure
  362. (described above)
  363. in which the member corresponding to ``optnum''
  364. has been initialized.
  365. .IP "uw_perror"
  366. When an error is reported by a \*(uw library routine,
  367. the cause of the error is saved in the external variable
  368. ``uwerrno''.
  369. If the error was UWE_ERRNO,
  370. the standard external variable ``errno''
  371. will also be meaningful.
  372. (The routines which operate upon external windows,
  373. described in the following section,
  374. also save this information in the window descriptor.)
  375. The routine ``uw_perror'' may be used to decode and print
  376. error messages:
  377. .DS
  378. void uw_perror(char *usermesg, uwerr_t uwerr, int err)
  379. .DE
  380. where ``usermesg'' is a pointer to a user-specified string,
  381. ``uwerr'' is the \*(uw error code
  382. (usually ``uwerrno''),
  383. and ``err'' is the system call error code
  384. (usually ``errno'').
  385. [System call error numbers are defined in ``/usr/include/errno.h''.]
  386. .sp
  387. The \*(uw error messages may also be accessed directly.
  388. Two external variables aid in user-formatted error messages:
  389. .DS
  390. extern char *uwerrlist[];
  391. extern unsigned uwnerr;
  392. .DE
  393. If the error number is greater than or equal to ``uwnerr'',
  394. no error message string exists.
  395. (This ``cannot happen.'')
  396. Otherwise,
  397. the error message string is obtained by indexing into
  398. ``uwerrlist''.
  399. .PP
  400. The preceeding routines are sufficient to implement
  401. a (simplified) version of the ``uwtool'' program,
  402. which creates a new
  403. (internal)
  404. window running a specified command:
  405. .DS
  406. .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n
  407. /*
  408.  *      uwtool
  409.  *
  410.  * Copyright 1986 by John D. Bruner.  All rights reserved.  Permission to
  411.  * copy this program is given provided that the copy is not sold and that
  412.  * this copyright notice is included.
  413.  */
  414. #include <strings.h>
  415. #include "uwlib.h"
  416.  
  417. main(argc, argv)
  418. int argc;
  419. char **argv;
  420. {
  421.         register uwid_t uwid;
  422.         register char *fname, *term;
  423.     register wtype_t wtype;
  424.         char *av[2];
  425.         union uwoptval optval;
  426.         extern int errno;
  427.         extern char *getenv();
  428.  
  429.         /*
  430.          * If called with no arguments, create a new window using the
  431.          * current shell according to the SHELL environment variable
  432.          * (or "/bin/sh" if that doesn't exist).  If called with
  433.          * arguments, argv[1] through argv[argc\-1] are the arguments
  434.          * to the command.
  435.          */
  436.         if (argc == 1) {
  437.                 if ((fname = getenv("SHELL")) == (char *)0)
  438.                         fname = "/bin/sh";
  439.                 av[0] = fname;
  440.                 av[1] = (char *)0;
  441.                 argv = av;
  442.         } else
  443.                 fname = *++argv;
  444.     
  445.     if ((term=getenv("TERM")) != (char *)0)
  446.         wtype = uw_ttype(term);
  447.     else
  448.         wtype = UWT_ADM31;
  449.         
  450.         if ((uwid = uw_cmd(wtype, fname, argv)) < 0) {
  451.                 (void)strncpy(optval.uwov_string, fname,
  452.                     sizeof optval.uwov_string);
  453.                 (void)uw_rsetopt(uwid, UWOP_TITLE, &optval);
  454.                 return(0);
  455.         } else {
  456.                 uw_perror("uwtool", uwerrno, errno);
  457.                 return(1);
  458.         }
  459. }
  460. .DE
  461. After the first part of the function has massaged the argument list,
  462. the ``uw_cmd'' routine creates a new window
  463. running the command ``fname'' with argument list ``argv''.
  464. If the window ID is positive,
  465. the window creation succeeded.
  466. After copying the name of the program into a ``union uwoptval'',
  467. the program calls ``uw_rsetopt'' to set the window title
  468. to that string.
  469. If the window ID returned by ``uw_cmd'' was \(mi1,
  470. the window creation failed.
  471. In this case,
  472. the program calls ``uw_perror'' to report the error.
  473. .SH
  474. External Window Interface
  475. .LP
  476. The remainder of the \*(uw library routines provide access to
  477. external windows.
  478. In contrast to internal windows,
  479. a client process creates an external window
  480. by establishing an Internet-domain stream connection
  481. to the server and sending the server a ``create window'' command.
  482. The server will establish a second stream connection
  483. back to the client.
  484. Data is passed between the client and the server on the first connection,
  485. while control information is passed through the second.
  486. [Because the server and client communicate through one or
  487. two stream connection(s)
  488. instead of by sending datagrams,
  489. the unreliability problems noted above for internal windows
  490. do not apply to external windows.]
  491. .LP
  492. The \*(uw library provides mechanisms for creating external windows,
  493. killing them,
  494. and manipulating window options.
  495. When a window is created a window descriptor
  496. (item of type UWIN)
  497. is returned;
  498. this is used as an argument to all other external-window routines.
  499. .LP
  500. The following routines are provided:
  501. .IP "uw_new" 1i
  502. This function creates a new external window of the specified type.
  503. The calling sequence is:
  504. .DS
  505. UWIN uw_new(uwtype_t uwtype, struct sockaddr_in *server)
  506. .DE
  507. where ``uwtype'' is the window type
  508. and ``server'' is a pointer to a structure specifying
  509. the Internet address of the server.
  510. (If ``server'' is a NULL pointer,
  511. the server will be determined by examining the
  512. environment variable ``UW_INET''.)
  513. If the window creation succeeded,
  514. ``uw_new'' will return a non-NULL window descriptor;
  515. otherwise,
  516. it will return NULL, and
  517. the global variables ``uwerrno'' and ``errno''
  518. may be examined to determine the cause of the error.
  519. .IP "uw_detach"
  520. This function ``detaches'' the window from the program
  521. so that it no longer is able to perform control operations
  522. upon the window.
  523. The data connection to the window remains open.
  524. This function should be used when the data connection to a window
  525. will be handled by a different process
  526. than the control connection,
  527. .I e.g.
  528. in a child process after a ``fork''.
  529. It is strongly recommended that no more than one process
  530. have control access to a window at any one time.
  531. The calling sequence is
  532. .DS
  533. uw_detach(UWIN uwin);
  534. .DE
  535. where ``uwin'' is the window descriptor.
  536. Zero is returned for success,
  537. while \(mi1 is returned for failure.
  538. If the routine fails,
  539. the error status will be stored in the UWIN data item
  540. as well as in the global variables ``uwerrno'' and ``errno''.
  541. .IP "uw_close"
  542. This function closes a window.
  543. Both the control and data connections to the window are closed.
  544. If multiple processes have access to a window
  545. (\fIe.g.\fP because of a ``fork''),
  546. then the window will be destroyed when the last connection
  547. to it is closed.
  548. The calling sequence is
  549. .DS
  550. uw_close(UWIN uwin);
  551. .DE
  552. where ``uwin'' is the window descriptor
  553. .IP "uw_kill"
  554. At times it may be desirable for one process to destroy
  555. a window even if the window is in use by other processes.
  556. The ``uw_kill'' function performs this task.
  557. The caller must have control access to the window
  558. (it must not be ``detached'').
  559. The syntax is:
  560. .DS
  561. uw_kill(UWIN uwin);
  562. .DE
  563. where ``uwin'' is the window descriptor.
  564. When a window is killed
  565. (either by ``uw_kill'' or upon command from the Macintosh)
  566. the server closes its data channel.
  567. Any further attempts to read or write to the window
  568. will produce end-of-file or error conditions,
  569. respectively.
  570. .IP "uw_optfn"
  571. If a process has control access to a window,
  572. then it will periodically receive
  573. window option messages from the Macintosh client
  574. (through the server).
  575. The \*(uw library receives these messages by enabling
  576. asynchronous I/O notification on the control channel
  577. and providing a SIGIO signal handler.
  578. Sometimes it is desirable for an external process
  579. to field incoming option messages itself.
  580. To do so,
  581. it must notify the \*(uw library by calling the
  582. routine ``uw_optfn'':
  583. .DS
  584. void (*uw_optfn(UWIN uwin, uwopt_t optnum, void (*optfn)())();
  585. .DE
  586. where ``uwin'' is the window descriptor,
  587. ``optnum'' is the desired window option,
  588. and ``optfn'' is a pointer to a function which
  589. will be called when a message about window option ``optnum''
  590. is received.
  591. ``uw_optfn'' returns the previous function.
  592. To disable processing for a window option,
  593. specify a NULL pointer for ``optfn''.
  594. The user-supplied ``optfn'' is called with the following arguments:
  595. .DS
  596. .ta 8n
  597. void (*optfn)(UWIN uwin, uwopt_t optnum, uwoptcmd_t optcmd,
  598.     union uwoptval *optval);
  599. .DE
  600. where ``uwin'' is the window descriptor,
  601. ``optnum'' is the window option number,
  602. ``optcmd'' is the window option command,
  603. and
  604. (if ``optcmd'' is UWOC_SET)
  605. ``optval'' is a pointer to the new value of the window option.
  606. .sp
  607. Because the \*(uw library provides a signal handler for SIGIO,
  608. if other portions of the program wish to catch SIGIO,
  609. then some care must be taken
  610. to ensure that all signal handlers are called.
  611. The \*(uw library saves the return value from
  612. ``signal'' when it installs its handler.
  613. If this is not SIG_IGN,
  614. then that routine will be called after \*(uw has
  615. completed its signal processing.
  616. In a similar fashion,
  617. if the calling program establishes a signal handler,
  618. it should save the previous value and call the indicated
  619. function
  620. (if not SIG_IGN).
  621. For example,
  622. if the caller uses ``signal'':
  623. .DS
  624. .ta 8n 16n
  625. oldhandler = signal(SIGIO, myhandler);
  626. \&...
  627. myhandler(sig, code, scp)
  628. int sig, code;
  629. struct sigcontext *scp;
  630. {
  631.     ... code to handle exception ...
  632.     if (oldhandler != SIG_IGN)
  633.         (*oldhandler)(sig, code, scp);
  634. }
  635. .DE
  636. Although from time to time
  637. the Macintosh may ask the server for the current
  638. value of a window option,
  639. the \*(uw server caches the current value of each
  640. window option
  641. and responds to these inquiries directly.
  642. Therefore,
  643. the major reason for establishing a window option function
  644. with ``uw_optfn'' is to process incoming UWOC_SET messages,
  645. .I i.e.
  646. messages from the Macintosh that the value of a window
  647. option has changed.
  648. .IP "uw_optcmd"
  649. This function allows a program with control access to a window
  650. to send window option commands.
  651. The calling sequence is
  652. .DS
  653. .ta 8n
  654. uw_optcmd(UWIN uwin, uwopt_t optnum, uwoptcmd_t optcmd,
  655.     union uwoptval *optval);
  656. .DE
  657. where ``uwin'' is the window descriptor,
  658. ``optnum'' is the window option number,
  659. ``optcmd'' is the command,
  660. and ``optval'' is a pointer to the option value.
  661. Of the six window option messages,
  662. only the UWOC_SET,
  663. UWOC_DO,
  664. and UWOC_DONT
  665. messages are very useful.
  666. UWOC_SET changes the value of a window option
  667. (``optval'' points to the new value).
  668. UWOC_DO and UWOC_DONT instruct the Macintosh to
  669. report or not report
  670. (respectively)
  671. when a user action changes the value of a window option there.
  672. When it creates a window,
  673. the \*(uw server instructs the Macintosh to report all
  674. changes to window options.
  675. Most programs will probably not need to issue UWOC_DO or UWOC_DONT commands.
  676. .IP uw_gvis
  677. This function fetches the current visibility
  678. status of a specified window:
  679. .DS
  680. int uw_gvis(UWIN uwin, int *vp);
  681. .DE
  682. ``vp'' is a pointer to an integer where the visibility status
  683. (0 or 1 for invisible or visible, respectively)
  684. is returned.
  685. Zero is returned for success,
  686. while \(mi1 is returned for failure.
  687. .IP uw_svis
  688. This function changes the visibility status of a specified window:
  689. .DS
  690. int uw_svis(UWIN uwin, int v);
  691. .DE
  692. If ``v'' is nonzero then the window ``uwin'' will be made visible;
  693. otherwise,
  694. the specified window will be made invisible.
  695. Zero is returned for success,
  696. while \(mi1 is returned for failure.
  697. .IP uw_gpos
  698. This function returns the current position on the screen
  699. of a specified window:
  700. .DS
  701. .ta 8n 20n 28n
  702. struct uwpoint {
  703.     unsigned    uwp_v;    /* vertical component */
  704.     unsigned    uwp_h;    /* horizontal component */
  705. };
  706.  
  707. int uw_gpos(UWIN uwin, struct uwpoint *pp);
  708. .DE
  709. Zero is returned for success,
  710. while \(mi1 is returned for failure.
  711. .IP uw_spos
  712. This function sets the position of a specified window to
  713. a desired location:
  714. .DS
  715. int uw_spos(UWIN uwin, struct uwpoint *pp);
  716. .DE
  717. Zero is returned for success,
  718. while \(mi1 is returned for failure.
  719. .IP uw_gwsize
  720. This function returns the current size in pixels
  721. of a specified window.
  722. The size is expressed as a ``uwpoint'',
  723. as defined above.
  724. .DS
  725. int uw_gwsize(UWIN uwin, struct uwpoint *pp);
  726. .DE
  727. Zero is returned for success,
  728. while \(mi1 is returned for failure.
  729. .IP uw_swsize
  730. This function sets a specified window to a new size:
  731. .DS
  732. int uw_swsize(UWIN uwin, struct uwpoint *pp);
  733. .DE
  734. .IP uw_gtitle
  735. This function returns the title of a specified window.
  736. The title has type ``uwtitle_t'':
  737. .DS
  738. typedef char uwtitle_t[256];
  739.  
  740. int uw_gtitle(UWIN uwin, uwtitle_t ttl);
  741. .DE
  742. Zero is returned for success,
  743. while \(mi1 is returned for failure.
  744. .IP uw_stitle
  745. This function sets the title of a specified window:
  746. .DS
  747. int uw_stitle(UWIN uwin, uwtitle_t ttl);
  748. .DE
  749. .IP uw_gtype
  750. This function returns the type of a specified window:
  751. .DS
  752. int uw_gtype(UWIN uwin, uwtype_t *tp);
  753. .DE
  754. ``tp'' points to a variable which receives the window type.
  755. Zero is returned for success,
  756. while \(mi1 is returned for failure.
  757. .IP uw_stype
  758. This function sets the type of a specified window:
  759. .DS
  760. int uw_stype(UWIN uwin, uwtype_t t);
  761. .DE
  762. ``t'' is the new window type.
  763. Zero is returned for success,
  764. while \(mi1 is returned for failure.
  765. .IP "UW_DATAFD"
  766. This macro extracts the file descriptor for the data connection
  767. from a window descriptor:
  768. .DS
  769. int UW_DATAFD(UWIN uwin);
  770. .DE
  771. .IP "UW_ID"
  772. This macro returns the unique window ID associated with a
  773. window descriptor:
  774. .DS
  775. uwid_t UW_ID(UWIN uwin);
  776. .DE
  777. .IP "UW_PERROR"
  778. When the \*(uw library detects an error
  779. it always places the error information into the
  780. global variables ``uwerrno'' and ``errno''.
  781. If the error is associated with a valid window descriptor,
  782. it will also store the information in the window descriptor.
  783. The macro ``UW_PERROR'' is used to print an error message
  784. according to the error status in a window descriptor:
  785. .DS
  786. void UW_PERROR(char *message, UWIN uwin);
  787. .DE
  788. where ``message'' is any user-supplied message and
  789. ``uwin'' is a window descriptor.
  790. .SH
  791. Copyright
  792. .LP
  793. This document copyright 1986 by John D. Bruner.
  794. Permission to copy is given,
  795. provided that the copies are not sold
  796. and that this copyright notice is included.
  797.